<?php 
	namespace Admin\Controller\User;
	use Think\Controller;
	class LoginController extends Controller{
		public function _initialize(){
			if(!empty(session('id'))){
				$this->success('您已登录,请退出之后在进入登录页面',U('admin/user/user/index'));die;
			}
		}
		public function index(){
			$this->display();
		}
		public function dologin(){
			// var_dump(I('post.'));
			$user = D('admin');
			$list['username'] = I('post.username');
			$list['password'] = md5(I('post.password'));
			$res = $user->where($list)->find();
			if(!$res){
				echo 'no';die;
			}
			session('id',$res['id']);

			$data = M('personal')->where('uid = '.session('id'))->find();
			session('user',$data);
			// var_dump(I('post.remember'));die;
			if(I('post.remember')==1){
				// echo 'aaa';die;
				// var_dump(cookie('username'));die;
				// ini_set('session.gc_maxlifetime',3600*24);
				// ini_set('session.cookie_lifetime',3600*24);
				$shuju['username'] = I('post.username');
				$shuju['password'] = I('post.password');
				cookie('user',$shuju,3600*24);
				// var_dump(cookie('user')['password']);
			}else{
				cookie('user',null);
			}
			if($res){
				echo 'yes';
			}else{
				echo 'no';
			}
		}
	}
?>